package top.xunfong.system.controller;

import jakarta.annotation.Resource;
import top.xunfong.common.core.domain.R;
import top.xunfong.system.entity.dto.RegisterDTO;
import top.xunfong.common.core.domain.model.LoginUserInfo;
import top.xunfong.system.service.SysUserService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @GetMapping("/userInfo")
    public R<LoginUserInfo> getUserInfo(String username) {
        return R.ok(sysUserService.getUserInfo(username));
    }

    /**
     * 注册
     *
     * @param dto
     * @return
     */
    @PostMapping("/register")
    public R<?> register(@RequestBody RegisterDTO dto) {
        sysUserService.register(dto);
        return R.ok();
    }

}